<template>
  <u-swiper 
  :list="bannerList" 
  :height="height" 
  @change="changeBanner"></u-swiper>
</template>
<script>
import { getbannerList } from "@/api";
import config from "@/common/config";
export default {
  props: {
    height: {
      type: Number,
      default: 130,
    },
    banner: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {
      bannerList: [],
    };
  },
  created() {
    this.bannerList = this.$props.banner;
    this.init();
  },
  methods: {
    async init() {
      try {
        const { id, roleName, roleAlias } = this.$store.getters.roleInfo;
        const pam = {
          appType: config.APP_TYPE, // app类型 // 默认 1 用户端  2 服务端（员工端）
          // roleId: id,
          isUse: 1, // 是否启用
          size: 10,
        };
        const { data, success } = await getbannerList(pam);
        if (success && data.records.length > 0) {
          this.bannerList = data.records.map(v => v.photoUrl);
        }
      } catch (error) {
        console.error(error);
      }
    },
    changeBanner(e) {
      this.$emit("changeBanner", e);
    },
    onBannerClick(e) {
      this.$emit("onBannerClick", e);
    },
  },
};
</script>
<style lang="scss"></style>
